package demo.Test;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @Auther: hjy(lc))
 * @Date: 2022/8/16-08-16-16:48
 * @Description：demo.Test
 */
public class demo3 {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        System.out.print("请输入孩子数量：");
        int num = sc.nextInt();
        int[] chinds = new int[num];
        System.out.println("请输入每个孩子的胃口");
        for (int i = 0; i < num; i++) {
            chinds[i] = sc.nextInt();
        }
        System.out.print("请输入饼干总量：");
        int cake = sc.nextInt();
        int[] cakes = new int[cake];
        System.out.print("请输入每块饼干大小：");
        for (int i = 0; i < cake; i++) {
            cakes[i] = sc.nextInt();
        }
        Arrays.sort(chinds);
        Arrays.sort(cakes);
        int count = 0;
        int j = 0;
        for (int i = 0; i < cake && j < num; i++) {
            if(cakes[i]<chinds[j]){
                continue;
            }
            count++;
            j++;
        }
        System.out.println("最多可以满足" + count + "位孩子的胃口");
    }
}
